//导入cookie模块
import {removeCookie,getCookie,setCookie} from './cookie.js'
$(".importHeard").load("./loginArea.html")
$(".importHeard")[0].onclick = function(e){
    var e = e ||window.event;
    var target = e.target ||e.srcElement;
    if(target.className == "dx"){
        target.parentNode.parentNode.style.display = "none"
    }
}

window.onload = function(){
    //判断是否登录成功
if(getCookie("username")&&getCookie("loginsucess")=="true"){
    var str =`
    <p class="logingo">您好，${getCookie("username")} &nbsp;&nbsp;&nbsp;&nbsp; <a href="./index.html">【退出登录】</a> </p>
    `
    $(".loginArea .logingo").html(str)
    $(".loginArea .logingo a").on("click",function(){
        document.cookie="loginsucess=false";
    })
}
    window.onscroll = function(){
        if(document.documentElement.scrollTop>=300){
            $(".importHeard .loginArea")[0].style.position = "fixed";
            $(".importHeard .loginArea")[0].style.top = "0px";
            $(".importHeard .loginArea")[0].style.width = '100%'
            $(".importHeard .rollS")[0].style.display = "block"
            $(".importHeard .rollS")[0].style.position = "fixed";
            $(".importHeard .rollS")[0].style.width = "100%"
            $(".importHeard .rollS")[0].style.top = "37px"
        }else{
            $(".importHeard .loginArea")[0].style.position = "relative";
            $(".importHeard .rollS")[0].style.display = "none"
        }
    }
}

